package org.qy137.controller;

import com.qy137.vo.ZoneVo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiOperation;
import org.qy137.service.ZoneService;
import org.qy137.utils.CommonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping({"zone"})
@ApiModel("封装返回客户端的数据实体")
public class ZoneController {
    @Autowired
    private ZoneService zoneService;

    public ZoneController() {
    }

    @ApiOperation("分页查询专区信息")
    @GetMapping({"getAllZone/{page}/{limit}"})
    public CommonResult getAllZone(@PathVariable Integer page, @PathVariable Integer limit, @RequestBody(required = false) ZoneVo zoneVo) {
        return this.zoneService.getAllZone(page, limit, zoneVo);
    }

    @ApiOperation("修改课程专区的显示状态")
    @PutMapping({"changeStatus/{id}/{isDisable}"})
    public CommonResult changeStatus(@PathVariable String id, @PathVariable Integer isDisable) {
        return this.zoneService.changeStatus(id, isDisable);
    }

    @ApiOperation("删除课程专区")
    @DeleteMapping({"deleteZone/{id}"})
    public CommonResult deleteZone(@PathVariable String id) {
        return this.zoneService.deleteZone(id);
    }

    @ApiOperation("添加或修改专区")
    @PostMapping({"addZone"})
    public CommonResult addZone(@RequestBody(required = false) ZoneVo zoneVo) {
        return this.zoneService.addZone(zoneVo);
    }
}
